﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cricket.LinqModel;

public partial class CricketAdmin : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["Admin"];
        if (!Page.IsPostBack)
        {
            
            if (cookie != null)
            {
                lblwelcome.Text = ("Welcome, " + cookie["AdminName"]);
                int userType = Convert.ToInt32(cookie["UserType"]);
                fillMenu(userType);
            }
            else
            {
                Response.Redirect("Login.aspx");

            }
        }
        cookie.Expires = DateTime.Now.AddMinutes(30);
        Response.Cookies.Set(cookie);
    }



    private void fillMenu(int userType)
    {
        HttpCookie cookie = Request.Cookies["Admin"];

        ltrMenu.InnerHtml = "<ul class='page-sidebar-menu'>";
        ltrMenu.InnerHtml += "<li><div class='sidebar-toggler hidden-phone'></div></li>";
        ltrMenu.InnerHtml += "<li class=<%=Request.Url.AbsolutePath.Contains('dashboard.aspx')?'start active':'' %><a href='dashboard.aspx'><i class='icon-home'></i><span class='title'>DASHBOARD</span><span class='selected'></span></a></li>";
        ltrMenu.InnerHtml += "<li id='liEntry' runat='server'><a href='javascript:;'><i class='icon-shopping-cart'>";
        ltrMenu.InnerHtml += "</i><span class='title'>Master</span> <span class='arrow '></span></a>";
        ltrMenu.InnerHtml += "<ul class='sub-menu'>";

        //Note: this is for super admin
        if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin) || userType == Convert.ToInt32(Enumeration.UserType.Admin))
        {
            if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin))
            {
                ltrMenu.InnerHtml += "<li id='liAdmin' runat='server'><a href='ViewBookie.aspx'>Admin</a></li>";
                
            }
            
            ltrMenu.InnerHtml += "<li id='liClient' runat='server'><a href='ViewClient.aspx'>Client</a> </li>";
            ltrMenu.InnerHtml += "<li id='liSetLimit' runat='server'><a href='SetLimit.aspx'>Set Limit</a> </li>";
            ltrMenu.InnerHtml += "<li id='liMyProfile' runat='server'><a href='MyProfile.aspx'>My Profile</a> </li>";

            if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin))
            {
                ltrMenu.InnerHtml += "<li id='liMatchSchedule' runat='server'><a href='ViewMatches.aspx'>Match Schedule</a></li>";
                ltrMenu.InnerHtml += "<li id='liSeries' runat='server'><a href='ViewSeries.aspx'>Series</a></li>";
                ltrMenu.InnerHtml += "<li id='liTeam' runat='server'><a href='ViewTeam.aspx'>Team</a></li>";
                ltrMenu.InnerHtml += "<li id='liMatchType' runat='server'><a href='ViewMatchType.aspx'>Match Type</a></li>";
                ltrMenu.InnerHtml += "<li id='liBettingType' runat='server'><a href='ViewBettingType.aspx'>Betting Type</a></li>";
                ltrMenu.InnerHtml += "<li id='liTossBetting' runat='server'><a href='AdminTossBetting.aspx'>Toss Betting</a></li>";
            }
            

            ltrMenu.InnerHtml += "</ul></li>";
        }
        ltrMenu.InnerHtml += "<li id='liBetting' runat='server'><a href='AddBetting.aspx'><i class='icon-shopping-cart'>";
        ltrMenu.InnerHtml += "</i><span class='title'>Betting</span></a>";
        if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin))
        {
            ltrMenu.InnerHtml += "<li id='liScore' runat='server'><a href='TeamScore.aspx'><i class='icon-shopping-cart'>";
            ltrMenu.InnerHtml += "</i><span class='title'>Score</span></a>";
        }

        if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin))
        {
            ltrMenu.InnerHtml += "<li id='liResult' runat='server'><a href='javascript:;'><i class='icon-shopping-cart'>";
            ltrMenu.InnerHtml += "</i><span class='title'>Result</span> <span class='arrow '></span></a>";
            ltrMenu.InnerHtml += "<ul class='sub-menu'>";
            ltrMenu.InnerHtml += "<li id='liSessionResult' runat='server'><a href='SessionResult.aspx'>Session</a></li>";
            ltrMenu.InnerHtml += "<li id='liEditSessionResult' runat='server'><a href='EditSessionResult.aspx'>Edit Session</a></li>";
            ltrMenu.InnerHtml += "<li id='liMatchResult' runat='server'><a href='MatchResult.aspx'>Match</a></li>";
            ltrMenu.InnerHtml += "</ul></li>";
        }

        ltrMenu.InnerHtml += "<li id='liReport' runat='server'><a href='javascript:;'><i class='icon-shopping-cart'>";
        ltrMenu.InnerHtml += "</i><span class='title'>Report</span> <span class='arrow '></span></a>";
        ltrMenu.InnerHtml += "<ul class='sub-menu'>";
        ltrMenu.InnerHtml += "<li id='liSessionReport' runat='server'><a href='SessionReport.aspx'>Session</a></li>";
        ltrMenu.InnerHtml += "<li id='li90110' runat='server'><a href='NineElevenReport.aspx'>90-110</a></li>";
        ltrMenu.InnerHtml += "<li id='liMatchReport' runat='server'><a href='MatchReport.aspx'>Match</a></li>";
        ltrMenu.InnerHtml += "<li id='liCommission' runat='server'><a href='AdminCommissionReport.aspx'>Commission</a></li>";
        ltrMenu.InnerHtml += "<li id='liLedger' runat='server'><a href='LedgerReport.aspx'>Ledger</a></li>";
        ltrMenu.InnerHtml += "</ul></li>";
        if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin))
        {
            ltrMenu.InnerHtml += "<li class='last '><a href='ClearData.aspx'><i class='icon-key'></i><span class='title'>Clear Record</span> </a></li>";
        }
        if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin) || userType == Convert.ToInt32(Enumeration.UserType.Admin))
        {

            ltrMenu.InnerHtml += "<li id='liClientLogot' runat='server'><a href='ClientLogout.aspx'><i class='icon-shopping-cart'>";
            ltrMenu.InnerHtml += "</i><span class='title'>Client Logout</span></a>";
        }
        if (userType == Convert.ToInt32(Enumeration.UserType.SuperAdmin))
        {
            ltrMenu.InnerHtml += "<li  id='liReloadClient' runat='server'><a href='ClientReload.aspx'><i class='icon-key'></i><span class='title'>Client Reload</span> </a></li>";
        }
        ltrMenu.InnerHtml +="<li class='last '><a href='Logout.aspx'><i class='icon-key'></i><span class='title'>Logout</span> </a></li>";
        ltrMenu.InnerHtml += "</ul></div>";


        //ltrMenu.InnerHtml += "<li id='liReports' runat='server'><a href='javascript:;'><span class='title'>Result</span>";
        //ltrMenu.InnerHtml += "<span class='arrow '></span></a>";
        //ltrMenu.InnerHtml += "<ul class='sub-menu'>";
        //ltrMenu.InnerHtml += "<li id='liSession' runat='server'><a href='SessionResult.aspx'>Session</a> </li>";
        //ltrMenu.InnerHtml += "<li id='liMatch' runat='server'><a href='MatchResult.aspx'>Match</a></li>";
        //ltrMenu.InnerHtml += "</ul></li>";

        //ltrMenu.InnerHtml += "<li id='liReport' runat='server'><a href='javascript:;'><i class='icon-shopping-cart'>";
        //ltrMenu.InnerHtml += "</i><span class='title'>Report</span> <span class='arrow '></span></a>";
        //ltrMenu.InnerHtml += "<ul class='sub-menu'>";
        //ltrMenu.InnerHtml += "<li id='liSessionReport' runat='server'><a href='SessionReport.aspx'>Session</a> </li>";
        //ltrMenu.InnerHtml += "<li id='liMatchReport' runat='server'><a href='MatchReport.aspx'>Match</a></li>";
        //ltrMenu.InnerHtml += "</ul></li>";
        //if (userType == Convert.ToInt32(Enumeration.UserType.Admin))
        //{
        //    ltrMenu.InnerHtml += "<li><a data-hover='dropdown' href='javascript:;'><span class='title'>Client</span>";
        //    ltrMenu.InnerHtml += "<span class='arrow '></span></a>";
        //    ltrMenu.InnerHtml += "<ul class='dropdown-menu'>";
        //    ltrMenu.InnerHtml += "<li><a href='AddClient.aspx'>Add Client</a> </li>";
        //    ltrMenu.InnerHtml += "<li><a href='ViewClient.aspx'>View Client</a></li>";
        //    ltrMenu.InnerHtml += "</ul>";
        //    ltrMenu.InnerHtml += "</li>";
        //}
        
    }
}
